package com.xingkeduo.pojo.enums;

import com.xingkeduo.util.pojo.base.BaseEnum;

/**
 * @Description:
 * @Author:gaozifeng
 * @Date 2019/2/26 11:22
 **/
public enum StatisticsEnums implements BaseEnum {
	MILD(1, "轻度用户"),
	MODE(4, "中度用户"),
	SEVE(7, "重度用户"),
	FANS(10, "忠实用户");

	private int value;
	private String desc;

	private StatisticsEnums(int value, String desc) {
		this.value = value;
		this.desc = desc;
	}

	public static boolean validValue(String value) {
		int value_int = Integer.parseInt(value);
		return validValue(value_int);
	}

	public static boolean validValue(int value) {
		StatisticsEnums[] yesnos = values();

		for (int i = 0; i < yesnos.length; ++i) {
			if (yesnos[i].getValue() == value) {
				return true;
			}
		}

		return false;
	}

	public static StatisticsEnums getStatistics(String value) {
		int value_int = Integer.parseInt(value);
		return getStatistics(value_int);
	}

	public static StatisticsEnums getStatistics(int value) {
		StatisticsEnums[] enums = values();

		for (int i = 0; i < enums.length; ++i) {
			if (enums[i].getValue() == value) {
				return enums[i];
			}
		}

		return null;
	}

	public static StatisticsEnums getStatisticsByRang(int value) {
		StatisticsEnums[] enums = values();

		for (int i = 0; i < enums.length; ++i) {
			if (i + 1 == enums.length)
				return enums[i];
			if (enums[i].value < value)
				return enums[i];
		}
		return null;
	}

	public int getValue() {
		return this.value;
	}

	public String getDesc() {
		return this.desc;
	}
}
